from djitellopy import Tello
import cv2

tello = Tello()
tello.connect()

#tello.takeoff()
tello.streamon()

while True:
    img = tello.get_frame_read().frame
    rgb_frame = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

    # 显示视频流
    cv2.imshow('Video Stream', rgb_frame)

    # 如果用户按下 'q' 键，则退出循环
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

#tello.land()
cv2.destroyAllWindows()